<?php

class Damages_Methods_Request_Login extends Damages_Methods_Request {

  public $email;
  public $password;

  public function __construct($params) {
    $this->email = $params->email;
    $this->password = $params->password;
    parent::__construct($params);
  }

  /**
   * 
   * @return Damages_Methods_Response
   * @throws Damages_Exception_App
   */
  public function process() {
    $authResult = Damages_Auth::getInstance()
            ->setLoginData(new Damages_AuthData_Email($this->email, $this->password))
            ->authenticate();
    if (!$authResult->isValid()) {
      throw new Damages_Exception_App(Damages_Codes::INCORRECT_LOGIN);
    }
    return new Damages_Methods_Response(true);
  }

}